#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ${package}.mapper.DemoMapper;
import ${package}.pojo.Demo;
import ${package}.service.DemoService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author qingchang.tang
 * @date 2020/1/7 15:03
 */

@Service
@Slf4j
@AllArgsConstructor
public class DemoServiceImpl implements DemoService {

    private final DemoMapper demoMapper;

    @Override
    public Long save(Demo o) {
        demoMapper.insertSelective(o);
        return o.getId();
    }

    @Override
    public Demo get(Long id) {
        return demoMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Demo> list(int page, int size) {

        PageHelper.startPage(page, size);
        List<Demo> data = demoMapper.selectAll();

        return new PageInfo<>(data);
    }

    @Override
    public int del(Long id) {
        return demoMapper.deleteByPrimaryKey(id);
    }

}
